#include <stdio.h>
#include <stdlib.h>

#define NUM 5

typedef struct HashList {
    char *data;
    int num;//个数
} HashList;

HashList *initHashList() 
{
    HashList *list = (HashList *)malloc(sizeof(HashList));
    list->num = 0; 
    list->data = (char *)malloc(sizeof(char) * NUM);
    for (int i = 0; i < NUM; i++) {
        list->data[i] = 0;
    }
    return list;
}

int hash(char data) 
{   
    return data % NUM;
}

void put(HashList *list, char data)
{
    int index = hash(data);
    if (list ->data[index] == 0) {//无冲突
        list->data[index] = data;
    } else {
        while (list->data[index] != 0) {
            index = hash(index+1);
        }
        list->data[index] = data;
        int count = 1;
    

    }
    list->num++;
}

int main(void)
{
    HashList *list = initHashList();
    put(list, 'A');
    put(list, 'B');
    printf("%c ", list->data[0]);
    printf("%c ", list->data[1]);
    printf("%d ", list->num);
    return 0;
}